/*
package com.deer.wms.base.system.web.rocketmq;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.deer.wms.base.system.finalUtil.*;
import com.deer.wms.base.system.service.bill.BillOutWorkService;
import com.deer.wms.base.system.service.bill.IBillOutDetailService;
import com.deer.wms.base.system.service.bill.IBillOutMasterService;
import com.deer.wms.base.system.service.box.AreaBoxItemService;
import com.deer.wms.base.system.service.box.BoxInfoService;
import com.deer.wms.base.system.service.box.BoxItemRecordService;
import com.deer.wms.base.system.service.box.IBoxItemService;
import com.deer.wms.base.system.service.task.ITaskInfoService;
import com.deer.wms.base.system.service.task.PickTaskService;
import com.deer.wms.base.system.service.task.TaskInfoHistoryService;
import com.deer.wms.base.system.service.ware.ICellInfoService;
import com.deer.wms.common.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.*;

@Component
@Slf4j
public class PushBillOutErrorConsumer implements CommandLineRunner {
    @Autowired
    private BillOutWorkService billOutWorkService;
    @Autowired
    private ITaskInfoService taskInfoService;
    @Autowired
    private BoxItemRecordService boxItemRecordService;
    @Autowired
    private IBoxItemService boxItemService;
    @Autowired
    private BoxInfoService boxInfoService;
    @Autowired
    private ICellInfoService cellInfoService;
    @Autowired
    private IBillOutDetailService billOutDetailService;
    @Autowired
    private PickTaskService pickTaskService;
    @Autowired
    private TaskInfoHistoryService taskInfoHistoryService;
    @Autowired
    private AreaBoxItemService areaBoxItemService;
    @Autowired
    private IBillOutMasterService billOutMasterService;
    @Autowired
    private RocketmqController rocketmqController;
//消费者
    @Value("${apache.rocketmq.consumer.pushConsumer}")
    private String pushConsumer;
//NameServer 地址


    @Value("${apache.rocketmq.namesrvAddr}")
    private String namesrvAddr;
//初始化RocketMq的监听信息，渠道信息

    @Value("${apache.rocketmq.consumer.clientIP}")
    private String clientIP;

    public void messageListener(){
        DefaultMQPushConsumer consumer=new DefaultMQPushConsumer("outErrorWarehouse");
        consumer.setNamesrvAddr(namesrvAddr);
        consumer.setClientIP(clientIP);
        try {
           consumer.subscribe(TopicName.TOPIC_BILLOUT_ERROR, "push");
            consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); // 程序第一次启动从消息队列头获取数据
            consumer.setConsumeMessageBatchMaxSize(1);//可以修改每次消费消息的数量，默认设置是每次消费一条
            //在此监听中消费信息，并返回消费的状态信息
            consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {
                // 会把不同的消息分别放置到不同的队列中
                for(Message msg:msgs){
                    Integer taskNumber= Integer.parseInt(convertMsgToJsonObj(msg).get("taskNumber").toString());
                    log.info("获得任务号taskNumber:" + taskNumber + ",开始更新\r\n" +msg.toString());
                    rocketmqController.BillOutError(taskNumber.longValue());

                }
                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
            });
            consumer.start();
        } catch (Exception e) {
            log.error("补发任务等出错了，回滚");
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }


    private JSONObject convertMsgToJsonObj(Message msg) {
        String taskInfoStr = JSONObject.toJSONString(JSONObject.parse(msg.getBody()));
        // String substring = taskInfoStr.substring(taskInfoStr.lastIndexOf("[") + 1, taskInfoStr.lastIndexOf("]"));
        JSONObject obj = (JSONObject) JSONObject.parse(taskInfoStr);
        return obj;
    }

    @Override
    public void run(String... args) throws Exception {
        new Thread(() -> {
            PushBillOutErrorConsumer pushBillOutConsumer =SpringUtils.getBean(PushBillOutErrorConsumer.class);
            pushBillOutConsumer.messageListener();
        }).start();
    }
}
*/
